<template>
    <div class="now-play-list" @click="">
        <single-now-song v-for="(item, index) of list.arr"
                         :index="index"
                         :key="index"
                         :id="item.id"
                         :name="item.name"
                         :arts="item.arts"></single-now-song>
    </div>
</template>

<script>
import {useStore} from "vuex";
import singleNowSong from "./singleNowSong.vue";
import {computed, onMounted, reactive, watch} from "vue";
export default {
    name: "nowPlayList",
    components:{
        singleNowSong
    },
    setup() {
        let store = useStore()

        let list = reactive({arr:[]})
        let isShow = computed(()=>store.state.playListStore.isShowNowPlayList)

        watch(isShow, value => {
            if (value == true) {
                list.arr = JSON.parse(localStorage.getItem('nowPlayList'))
            }
        })

        onMounted(()=>{
            list.arr = JSON.parse(localStorage.getItem('nowPlayList'))
        })

        return {
            list
        }
    }
}
</script>

<style lang="less" scoped>


.now-play-list {
    margin: 10px;
    padding: 10px;
    bottom: 71px;
    right: 0;
    position: absolute;
    width: 300px;
    height: 300px;
    background-color: rgb(52, 51, 50);
    border-radius: 5px;
    box-shadow: 0 0 10px gray;
    overflow-y: scroll;
    &::-webkit-scrollbar {/*滚动条整体样式*/
        width: 10px;     /*高宽分别对应横竖滚动条的尺寸*/
        height: 1px;
        padding: 5px;
    }
    &::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
        border-radius: 10px;
        //-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
        background: #535353;
    }
    &::-webkit-scrollbar-track {/*滚动条里面轨道*/
        border-radius: 10px;
        background: rgb(52, 51, 50);
    }
}
</style>